import sys
from os import path
def input():
return sys.stdin.readline().strip()
def solve(n, s):
for i in range(2, n-1):
if s[:i].count(s[i:i+2]):
print("YES")
return
else:
continue
print("NO")
def main():
testcases = int(input()) for _ in range(testcases):
n = int(input())
s = input()
solve(n, s)
if __name__ == "__main__":
if path.exists('Tests'):
sys.stdin = open("Tests/input_1.txt", "r")
sys.stdout = open("Tests/output_1a.txt", "w")
main()
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int pos=0;
map<string,int> m;
for(int i=0;i<n-1;i++)
{
string temp="";
temp.push_back(s[i]);
temp.push_back(s[i+1]);
// cout<<"curr subs="<<temp<<" ";
if(m.find(temp)==m.end())
{
m[temp]=i;
}
else
{
if(m[temp]!=i-1)
{
pos=1;
break;
}
}
}
if(pos==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
411A - Password Check | 1520C - Not Adjacent Matrix |
1538B - Friends and Candies | 580A - Kefa and First Steps |
1038B - Non-Coprime Partition | 43A - Football |
50A - Domino piling | 479A - Expression |
1480A - Yet Another String Game | 1216C - White Sheet |
1648A - Weird Sum | 427A - Police Recruits |
535A - Tavas and Nafas | 581A - Vasya the Hipster |
1537B - Bad Boy | 1406B - Maximum Product |
507B - Amr and Pins | 379A - New Year Candles |
1154A - Restoring Three Numbers | 750A - New Year and Hurry |
705A - Hulk | 492B - Vanya and Lanterns |
1374C - Move Brackets | 1476A - K-divisible Sum |
1333A - Little Artem | 432D - Prefixes and Suffixes |
486A - Calculating Function | 1373B - 01 Game |
1187A - Stickers and Toys | 313B - Ilya and Queries |